package com.fk.his.domain.common.exception;


import com.fk.his.domain.common.enums.ErrorCodeEnums;

/**
 * <p>
 * 自定义业务异常
 * <p>
 * 示例代码
 * <pre>
 * </pre/>
 *
 * @author InHome
 * @version BME V100R001 2023/03/27
 * @since BME V100R001C40B104
 */
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private static final Integer DEFAULT_CODE = 500;
    /**
     * 错误码
     */
    protected Integer code = DEFAULT_CODE;

    /**
     * 错误枚举-初始化
     */
    public BusinessException(ErrorCodeEnums errorCode) {
        this(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    /**
     * 错误消息-初始化
     */
    public BusinessException(String message) {
        super(message);
    }

    /**
     * 异常消息、异常链-初始化
     */
    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public Integer getCode() {
        return this.code;
    }
}
